/*
 * @Author: 菜单界面
 * @Date: 2020-06-01 15:27:27
 * @LastEditTime: 2020-06-04 16:59:49
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \idiom_demo\assets\script\menu\menu.ts
 */ 
import { SM } from "../SceneManager"

const {ccclass, property} = cc._decorator;

@ccclass
export class Menu extends cc.Component {

    // 声音 图片
    @property({
        type: cc.SpriteFrame,
    })
    voice_open: cc.SpriteFrame = null;
    @property({
        type: cc.SpriteFrame,
    })
    voice_close: cc.SpriteFrame = null;

    // 三个按钮
    @property(cc.Node)
    rank_btn: cc.Node = null;
    @property(cc.Node)
    voice_btn: cc.Node = null;
    @property(cc.Node)
    start_btn: cc.Node = null;

    onLoad () {
        // 初始化
        this.init();
    }

    private addListener() {
        this.rank_btn.on(cc.Node.EventType.TOUCH_END, this.onRankTouched, this);
        this.voice_btn.on(cc.Node.EventType.TOUCH_END, this.onVoiceTouched, this);
        this.start_btn.on(cc.Node.EventType.TOUCH_END, this.onStartTouched, this);
    }

    // 初始化
    private init() {
        this.addListener();
    }

    // 排行榜按钮回调
    private onRankTouched() {
        cc.log("点击排行榜");
    }

    // 音效回调
    private onVoiceTouched() {
        cc.log("点击声音");
    }

    // 开始按钮回调
    private onStartTouched() {

        SM.enterGameScene();
    }
}